/**
* COPYRIGHT. whx. ALL RIGHTS RESERVED.
* Project: just-core
* Author: whx <harrywu304@gmail.com>
* Create On: Apr 12, 2012 5:12:43 PM
*/

package org.justframework.api.connector;

import org.justframework.api.exception.ConnectFailureException;
import org.justframework.util.UriUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *Basic client connector
 */
public abstract class BaseClient implements ClientConnector {
	
	/**
	 * logger
	 */
	private static Logger logger = LoggerFactory.getLogger(BaseClient.class);

	/* (non-Javadoc)
	 * @see org.justframework.api.connector.ClientConnector#rpc(org.justframework.api.connector.Request)
	 */
	@Override
	public Response rpc(Request request) {
		//stamp request timestamp
		request.setRequestTimestamp(System.currentTimeMillis());
		logger.debug("requestObject [{}]", request);
		
		Response response = doRpc(request);
		
		//stamp response return timestamp
		response.setReturnTimestamp(System.currentTimeMillis());
		logger.debug("responseObject [{}]", response);
		return response;
	}
	
	public abstract Response doRpc(Request request);

}
